#include<bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
inline int max(int a,int b){
    return a>b?a:b;
}inline int min(int a,int b){
    return a<b?a:b;
}
set<pii> st;
int vis[100007];
int a[100007],now[100007],nows[100007],ans=0;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;cin>>n;
    int nowmin=0x7f7f7f;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        now[a[i]]++;
        nows[a[i]]++;
        nowmin=min(nowmin,a[i]);
    }int j=nowmin+1;
    for(int i=nowmin;i<100000;++i){
        while(now[i]){
            while(j<=i||j<=100000&&!nows[j]){
                ++j;
            }if(j>100000)break;
            now[i]--;
            nows[i]--;
            nows[j]--;
        }
    }for(int i=1;i<=100000;++i){
        ans+=now[i];
    }cout<<ans;
    return 0;
}
